﻿using System;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;

namespace QAToolsAddin.GenericDialogs {
    public static class MsgBox {
        public static DialogResult ShowWarn(Excel.Application excelapp, string pMessage) {
            return MessageBox.Show(new Wrapper(excelapp.Hwnd), pMessage + "   ", "Warn", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public static DialogResult ShowWarn(Excel.Application excelapp, string pMessage, MessageBoxButtons buttons) {
            return MessageBox.Show(new Wrapper(excelapp.Hwnd), pMessage + "   ", "Warn", buttons, MessageBoxIcon.Exclamation);
        }

        public static DialogResult ShowInfo(Excel.Application excelapp, string pMessage) {
            return MessageBox.Show(new Wrapper(excelapp.Hwnd), pMessage + "   ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        public static DialogResult ShowError(Excel.Application excelapp, string pMessage) {
            return MessageBox.Show(new Wrapper(excelapp.Hwnd), pMessage + "   ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        public static DialogResult ShowQuestion(Excel.Application excelapp, string pMessage) {
            return MessageBox.Show(new Wrapper(excelapp.Hwnd), pMessage + "   ", "Input", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
        }

        private class Wrapper : IWin32Window {
            readonly IntPtr _handle;

            public Wrapper(int hwnd) {
                _handle = new IntPtr(hwnd);
            }

            public IntPtr Handle {
                get { return _handle; }
            }
        }

    }
}
